package com.ftqh.project.travel.notes.service;

import com.ftqh.project.travel.notes.entity.Note;
import com.ftqh.project.travel.notes.repository.NoteRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * Created by Administrator on 2017/5/8.
 */
@Service
public class NoteServiceImpl implements NoteService {
    @Autowired
    NoteRepository noteRepository;
    @Override
    public List<Note> findAll() {
        return noteRepository.findAll();
    }

    @Override
    public Optional<Note> findById(Long id) {
        return Optional.of(noteRepository.findOne(id));
    }

    @Override
    public List<Note> findByAuthorName(String authorName) {
        return noteRepository.findByAuthorName(authorName);
    }

    @Override
    public void save(Note note) {
        noteRepository.save(note);
    }

}
